// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   ChartAndroidImage.java

package com.java4less.rchart.gc.android;

import android.content.res.AssetManager;
import android.graphics.*;
import android.util.Log;
import com.java4less.rchart.android.ChartPanel;
import com.java4less.rchart.gc.*;
import java.io.*;

// Referenced classes of package com.java4less.rchart.gc.android:
//			ChartAndroidGraphics

public class ChartAndroidImage extends ChartImage
{

	private Bitmap image;
	public static AssetManager assets;

	public ChartAndroidImage(Object o)
	{
		image = null;
		if (o instanceof String)
		{
			if (assets != null)
				try
				{
					InputStream is = assets.open((String)o);
					image = BitmapFactory.decodeStream(is);
					is.close();
				}
				catch (IOException e)
				{
					Log.e(ChartPanel.TAG, (new StringBuilder()).append("Cannot open file ").append(o).toString(), e);
				}
			else
				image = BitmapFactory.decodeFile((String)o);
		} else
		if (o instanceof InputStream)
			image = BitmapFactory.decodeStream((InputStream)o);
		else
		if (o instanceof Bitmap)
			image = (Bitmap)o;
	}

	public ChartAndroidImage(int w, int h, ChartColor transparent)
	{
		image = null;
		image = Bitmap.createBitmap(w, h, android.graphics.Bitmap.Config.ARGB_8888);
	}

	public ChartAndroidImage(int w, int h)
	{
		image = null;
		image = Bitmap.createBitmap(w, h, android.graphics.Bitmap.Config.ARGB_8888);
	}

	public ChartGraphics getGraphics()
	{
		if (image == null)
			return null;
		else
			return new ChartAndroidGraphics(new Canvas(image));
	}

	public int getWidth()
	{
		if (image == null)
			return 1;
		else
			return image.getWidth();
	}

	public int getHeight()
	{
		if (image == null)
			return 1;
		else
			return image.getHeight();
	}

	public Bitmap getImage()
	{
		return image;
	}

	public boolean saveToStream(String sFormat, OutputStream os)
	{
		return false;
	}
}
